package com.nf.action;

import com.nf.entity.Car;
import com.nf.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.awt.ModalExclude;

import java.util.List;

@Controller
public class CarAction {

    @Autowired
    private CarService carService;


    @RequestMapping("/indexView")
    public String index(){
        return "index";
    }

    //后端
    @RequestMapping("/bb")
    @ResponseBody
    public List<Car> bb(){
        List<Car> carList = carService.getAllCars();
        return carList;
    }


    @RequestMapping("/kk")
    public String kk(Model model){
        System.out.println("service:"+carService);
        List<Car> carList = carService.getAllCars();
        model.addAttribute("carList",carList);
        return "a1";
    }

    @RequestMapping("/kk2")
    @ResponseBody
    public List<Car> kk2(){
        List<Car> carList = carService.getAllCars();
        return carList;
    }

    @RequestMapping("/kk3")
    public String kk3(){
        System.out.println("1.接受了请求");
        carService.insertCar();
        return "a1";
    }

    @RequestMapping("/kk4")
    public String kk4(String name,Integer id,String sex){

        System.out.println(sex);

        return "a2";
    }

    @RequestMapping("/insertView.cgi")
    public String kk5(){

        return "insert";
    }

}
